<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="java.util.*,
						org.apache.commons.logging.Log, 
						org.apache.commons.logging.LogFactory,
						com.ophelisis.common.util.*,
						com.ophelisis.common.consts.*,
						com.ophelisis.actions.system.*"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="page" uri="/tld/xdp-page.tld"%>

<script>
var events = [];
var event_id = [];
var event_nm = [];
var event_start = [];
var event_end = [];

var frameModule = {
		init: function() {
			frameModule.setUnbinding();
			frameModule.setBinding();
		},
		
		setBinding: function() {
			var that = this;

			$(".fc-event").bind({
				click: function(e){
					that.getDetail($(this).find(".fc-event-title").attr("id"));
				}
			});
		},
		
		setUnbinding: function() {
			$(".fc-event").unbind();
		},
		
		getDetail: function(calendarId) {
			parent.$("#_prevCode").val(calendarId);
			parent.$("#_startDay").val("");
			parent.$("#_endDay").val("");

			parent.frame_popup("boardCalendarMgmt.action?target=bmDetail&" + $("#commonForm").serialize(), (checkUserAuth() < 2 ? "상세 일정" : "상세 일정 :: 수정 모드"), 660, 380);
		}
};

$(document).ready(function() {
	<c:forEach var="list" items="${calendarList}" varStatus="status">
		event_id[<c:out value='${status.index}'/>] = "<c:out value='${list.calendarId}'/>";
		event_nm[<c:out value='${status.index}'/>] = "<c:out value='${list.calendarNm}'/>";
		event_start[<c:out value='${status.index}'/>] = new Date("<c:out value='${list.startYear}'/>","<c:out value='${list.startMonth - 1}'/>","<c:out value='${list.startDay}'/>");
		event_end[<c:out value='${status.index}'/>] = new Date("<c:out value='${list.endYear}'/>","<c:out value='${list.endMonth - 1}'/>","<c:out value='${list.endDay}'/>");
	</c:forEach>
	
	for (var i = 0; i < event_id.length; i++) {
		events.push({
			id: event_id[i],
			title: event_nm[i],
			start: event_start[i],
			end: event_end[i]
		});
	}

	parent.$("#calendar").fullCalendar("removeEvents");
	parent.$("#calendar").fullCalendar("addEventSource", events);

	frameModule.init();
});
</script>
<!-- Title Start -->
